from EWOA import WhaleOptimizationAlgorithm_Enhanced
from EWOA2 import WhaleOptimizationAlgorithm_Enhanced2
from WOA import WhaleOptimizationAlgorithm
from WOAWC import WhaleOptimizationAlgorithm_AdaptiveWeightAndCauchyVariation
from testFunctions import f1, f5, f6
from matplotlib import pyplot as plt

population_numbers = 100
dimension = 20
iterations = 100

upper_bounds = [30 for i in range(dimension)]
lower_bounds = [-30 for i in range(dimension)]

func = f5

xl1 = WhaleOptimizationAlgorithm(n=population_numbers, d=dimension, T=iterations,
                                 ub=upper_bounds, lb=lower_bounds, f=func)

xl2 = WhaleOptimizationAlgorithm_AdaptiveWeightAndCauchyVariation(n=population_numbers, d=dimension, T=iterations,
                                                                  ub=upper_bounds, lb=lower_bounds, f=func)

xl3 = WhaleOptimizationAlgorithm_Enhanced(n=population_numbers, d=dimension, T=iterations,
                                          ub=upper_bounds, lb=lower_bounds, f=func)

xl4 = WhaleOptimizationAlgorithm_Enhanced2(n=population_numbers, d=dimension, T=iterations,
                                           ub=upper_bounds, lb=lower_bounds, f=func)

plt.title('Comparison of Algorithm Performance(f1)')
plt.xlabel('Epoch')
plt.ylabel('Fitness value')

plt.plot([i for i in range(iterations)], xl1, 'b')
plt.plot([i for i in range(iterations)], xl2, 'r')
plt.plot([i for i in range(iterations)], xl3, 'g')
plt.plot([i for i in range(iterations)], xl4, 'k')

plt.legend(labels=["WOA", "WOAWC", "EWOA", "EWOA2"])
plt.show()

